<?php
require './include/global.php';
require './include/validate.php';
require './include/all_left.php';

require_once './include/advisory_db.php';
//print_r($_SESSION);
$smarty->compile_check = true;

$smarty->display('header.tpl');
$smarty->assign("copname","Find Candidate");
if($_GET[country]==''){
$_GET[country] = 211;
}
$smarty->assign('s',$_GET);
//jobupdate
$smarty->assign('jobupdate_names',$UPDATE);
$smarty->assign('state',$state);
$smarty->assign('country',$country);
$smarty->assign('industry',$jobcategory);
$smarty->assign('function',$jobfunction);
$smarty->assign('salary',$salary);
$smarty->assign('jobtype',$jobtype);
$smarty->assign('rec_findresume',$rec_findresume);		


//print_r($findresume_orderby);
$where = "  WHERE 1=1 AND re_private = '0' ";
//if($_GET[action]!='search') $where .= " AND re_aliasid = '0'  ";
$order = " ORDER BY re_id DESC";

if($_GET[action]=="search"){ 

	if( $_GET[keywords]!=''){ $arr[] = " (`re_jobtitle`  like '%".$_GET[keywords]."%' OR `re_detail` like '%".$_GET[keywords]."%' ) ";}	
	if($_GET[orderby]=='0'){$by = "re_id";}
	else{
		$ord   = array('','re_locity','re_lostate','re_locountry','re_jobindustry','re_jobtitle','re_jobtype','re_proflicense','re_regtime');
		$by = $ord[$_GET[orderby]];
	}
    if(empty($by)){ $by = "re_id";}
	if($_GET[city]!='')      { $arr[] = " `re_locity` like '%".$_GET[city]."%' ";}
    if($_GET[state]!='0')    { $arr[] = " `re_lostate` = '".$_GET[state]."'  ";}
	if($_GET[country]!='0')  { $arr[] = " `re_locountry` = '".$_GET[country]."'  ";}
	if($_GET[industry]!='0') { $arr[] = " `re_jobindustry` = '".$_GET[industry]."'  ";}
	if($_GET[jobtitle]!='')  { $arr[] = " `re_jobtitle`  like '%".$_GET[jobtitle]."%'  ";}	
	if($_GET[jobtype]!='0' ) { $arr[] = " `re_jobtype`  =  '".$_GET[jobtype]."'  ";}
	if($_GET[certif]!='' )   { $arr[] = " `re_proflicense` like '%".$_GET[certif]."%'  ";}
    if($_GET[jobupdate]!='') { $arr[] = " (UNIX_TIMESTAMP( ) - `re_regtime`) < (3600*24*".$_GET[jobupdate].")" ;}
	if($_GET[alias]!=1)      { $arr[] = "  re_aliasid = '0'  "; }

	//print_r($arr);
	if(!empty($arr)) {
		$implode  = @implode("AND", $arr);
		$implode  = " AND ".$implode;
		$where    .= $implode;
	}
    $order = " ORDER BY $by DESC ";
}

//echo "SELECT * FROM pa_resume $where $order";
$nav = new buildNav;
$total = $DB->fetch_one_array("SELECT COUNT(*) AS count FROM pa_resume $where");
$nav->total_result = $total[count];
//echo "SELECT * FROM pa_resume $where $order";
$nav->execute("SELECT * FROM pa_resume $where $order");

$page = $nav->pagenav();
//echo $sql2;

$i=0;
while($list2 = $DB->fetch_array($nav->sql_result)){
   $datajob[$i]              = $list2;
   $datajob[$i][name]        = $list2[re_fname]." ".$list2[re_lname] ;
   $datajob[$i][industry]    = $jobcategory[$list2[re_jobindustry]];
   $datajob[$i][location]    = $state[$list2[re_lostate]].",".$country[$list2[re_locountry]];
   $datajob[$i][re_jobtype]  = $jobtype[$list2[re_jobtype]];
   $aliasnum                 = $DB->fetch_one_array("SELECT re_id FROM pa_resume WHERE re_fid = '".$datajob[$i][re_id]."'");

   if(!empty($aliasnum)){
      $datajob[$i][alias]    = 1;
   }
   $i++;
}
$smarty->assign("resumelist",$datajob);
$smarty->assign("page",$page);
if($err!=''){
$smarty->assign("err",$err);
}
$smarty->assign("search",$reg_data);
$smarty->display('allleft.tpl');
$smarty->display('findresume.tpl');
$smarty->display('footer.tpl');
?>